package com.bckj.fastboot.iot.task.scheduling.job;

import com.bckj.fastboot.iot.common.service.IotDeviceScheduledService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.Instant;

/**
 * IotDeviceHeartbeatCheckJob
 *
 * @author wfc
 **/
@Slf4j
@Component
public class IotDeviceHeartbeatCheckJob {

    @Resource
    private IotDeviceScheduledService iotDeviceScheduledService;

    @Scheduled(cron = "0 0/30 * * * ?")
    public void execute() {
        log.info("IotDeviceHeartbeatCheckJob execute begin >>>");
        Instant start = Instant.now();
        iotDeviceScheduledService.checkHeartbeat();
        log.info("IotDeviceHeartbeatCheckJob execute end, ms={} <<<", Instant.now().toEpochMilli() - start.toEpochMilli());
    }
}
